package com.amos.exception;

/**
 * Copyright © 2018 嘉源锐信. All rights reserved.
 *
 * @Project: mu-exam
 * @ClassName: BizExceptionEnum
 * @Package: com.amos.exception
 * @author: zhuqb
 * @Description:
 * @date: 2020/3/24 0024 下午 15:45
 * @Version: V1.0
 */
public enum BizExceptionEnum implements BizExceptionAssert {

    /**
     * 异常编码 1000
     * 异常信息 对象不能为空
     */
    NOT_NULL(1000, "对象不能为空"),
    /**
     * 自定义异常 9999
     */
    DEFINED_EXCEPTION(9999, "系统异常");

    /**
     * 编码
     */
    private Integer code;
    /**
     * 信息
     */
    private String msg;

    BizExceptionEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    /**
     * 此处可以动态修改msg的返回值
     * 这么做是为了实现自定义异常信息
     *
     * @param msg
     * @return
     */
    public BizExceptionEnum definedMsg(String msg) {
        this.msg = msg;
        return this;
    }
}
